package zh.javadesign.工厂方法.impl02;

import zh.javadesign.工厂方法.impl01.AwardReq;
import zh.javadesign.工厂方法.impl02.store.ICommondity;

import java.util.HashMap;
import java.util.Map;

/**
 * Copyright (C) 广州中和互联网技术有限公司
 * 测试工厂方法模式发放奖品
 * @author 范家微 fanjiawei@borche.cn
 * @date :2021/1/29 11:51
 */
public class ApiTest {
	public static void main(String[] args) {
		StoreFactory storeFactory = new StoreFactory();
		// 1. 第三方兑换卡(爱奇艺)
		AwardReq awardReq = new AwardReq().setBizId("1234").setAwardType(1).setAwardNumber("3445").setUId("0000");
		ICommondity commodityService = storeFactory.getCommodityService(awardReq.getAwardType());
		commodityService
				.sentCommodity(awardReq.getUId(), awardReq.getAwardNumber(), awardReq.getBizId(), awardReq.getExtMap());

		// 2. 优惠券
		ICommondity commodityService_1 = storeFactory.getCommodityService(1);
		commodityService_1.sentCommodity("10001", "EGM1023938910232121323432", "791098764902132", null);

		// 3. 实物商品
		ICommondity commodityService_2 = storeFactory.getCommodityService(2);
		Map<String,String> extMap = new HashMap<String,String>();
		extMap.put("consigneeUserName", "谢飞机");
		extMap.put("consigneeUserPhone", "15200292123");
		extMap.put("consigneeUserAddress", "吉林省.长春市.双阳区.XX街道.檀溪苑小区.#18-2109");

		commodityService_2.sentCommodity("10001","9820198721311","1023000020112221113",new HashMap<String, String>() {{
			put("consigneeUserName", "谢飞机");
			put("consigneeUserPhone", "15200292123");
			put("consigneeUserAddress", "吉林省.长春市.双阳区.XX街道.檀溪苑小区.#18-2109");
		}});
	}
}
